package top.anka1.ims.BouncingShapes.bouncebox;

import top.anka1.ims.BouncingShapes.bounceboxframework.Shape;

import java.awt.*;

public class Triangle extends Shape {
    private int base;
    private int height;

    public Triangle(int x, int y, int base, int height) {
        super(x,y);
        this.base = base;
        this.height = height;
    }
    public int getBase(){return base;}
    public int getHeight(){return height;}
    public double getContactRadius() {return Math.sqrt((double) (base * base) /4 + (double) (height * height) /4);}
    public double getMass() {return base * height * 0.5;}
    public void draw(Graphics2D g) {
        g.setColor(getColor());
        int[] xPoints = {(int)getX(), (int)(getX() - (double) base /2), (int)(getX() + (double) base /2)};
        int[] yPoints = {(int)getY(), (int)(getY() + height), (int)(getY() + height)};
        g.fillPolygon(xPoints, yPoints, 3);
    }
}
